#include<iostream>
using namespace std;

class complex{
    public:
    complex(int real,int image)
    :_real(real)
    ,_image(image)
    {}
    void print () const
    {
        cout << _real <<"+" << _image <<"i" << endl;
    }
    //这里传一个参数就可以，因为有个this指针，可以找到自己类中成员的值
    complex operator +(const complex &lhs)
    {
        return complex(_real+lhs._real , _image+lhs._image);
    }

    private:
    int _real;
    int _image;
};

void test0()
{
    complex c1(2,3);
    complex c2(3,5);
    //会调用默认的拷贝构造
    complex c3 = c1 + c2;
    c3.print();

    complex c4 = c1.operator+(c2); //本质
    c4.print();

}
int main()
{
    test0();
    return 0;
}